#ifndef _EVENTSYSTEM_H__
#define _EVENTSYSTEM_H__

#include"Event System/IEventData.h"
#include"Event System/IEventListener.h"

#include<map>
#include<vector>
#include<queue>
#include<windows.h>

typedef std::vector<EventListenerPtr> EventListenerList;
typedef EventListenerList::iterator EventListenerListItr;

typedef std::pair<EventType, EventListenerList*> EventListenerListPair;

typedef std::multimap<EventType, EventListenerList*> EventListenerMap;
typedef EventListenerMap::iterator EventListenerMapItr;

typedef std::queue<IEventDataPtr> EventDataQueue;



class EventSystem
{
private:
	EventListenerMap mEventListenerMap;
	EventDataQueue mQueue[2];

	int mNumQueues;
	int mActiveQueue;

	static EventSystem* gpEventSystem;

public:
	EventSystem();

	static bool Create();

	static EventSystem* GetEventSystem();

	bool AddListener(EventListenerPtr inListener, EventType inType);
	bool RemoveListener(EventListenerPtr inListener);
	bool ValidateListener(EventListenerPtr inListener);

	bool QueueEvent(IEventDataPtr inEvent);
	bool TriggerEvent(IEventDataPtr inEvent);

	bool Update(float maxMilliseconds = -1);  
};

#endif